package com.jmebananas.input.action;

import com.jme.input.MouseInput;
import com.jme.input.action.InputActionEvent;
import com.jme.input.action.MouseInputAction;
import com.jme.math.FastMath;
import com.jme.renderer.Camera;

/**
 * MousePan
 * 
 * @author Glenn Powell
 * 
 */
public class MouseScrollZoomAction extends MouseInputAction {

	private KeyZoomAction keyZoom;

	private InputActionEvent event;


	public MouseScrollZoomAction(Camera camera, float speed) {
		this.speed = speed;

		keyZoom = new KeyZoomAction(camera, speed);

		event = new InputActionEvent();
	}

	public void setSpeed(float speed) {
		super.setSpeed(speed);
		keyZoom.setSpeed(speed);
	}

	public void performAction(InputActionEvent evt) {
		int mouseWheel = MouseInput.get().getWheelDelta();
		if (mouseWheel != 0) {
			event.setTime(FastMath.sign(mouseWheel));
			keyZoom.performAction(event);
		}
	}
	
}